#ifndef __FILE_H_
#define __FILE_H_

#include "Page.h"
#include "Record.h"

class File {

        Page myBuff;
        int curLength;
        int curPos;
        int changed;
        int myFilDes;
        char *path;

public:

        // returns the current length of the file, in pages
        int GetLength ();

        // opens the given file; the first parameter tells whether or not to
        // create the file.  If the parameter is zero, a new file is created
        // the file; if notNew is zero, then the file is created and any other
        // file located at that location is erased.  Otherwise, the file is
        // simply opened
        void Open (int notNew, char *fName);

        // moves the record "pointer" in the file to the first record on
        // the specified page in the file
        void MovePointer (int whichPage);

        // gets the next record in the file; returns a 0 if there are no more
        // records and a 1 otherwise
        int NextRec (Record &getMe);

        // adds a new record to the very end of the file and returns the page number
        int Append (Record &addMe);

        // allows someone to explicitly get a specified page from the file
        int GetPage (Page &putItHere, int whichPage);

        // allows someone to explicitly write a specified page to the file
        // if the write is past the end of the file, all of the new pages that
        // are before the page to be written are zeroed out
        void AddPage (Page &addMe, int whichPage);

        // closes the file and returns the file length (in number of pages)
        int Close ();

        // closes the file and removes it from disk
        void Kill ();

        File ();
        ~File ();
};



#endif /* __FILE_H_ */
